load('litter.Rdata')We can utilize Baltimore’s latest 311 database to inform when to alert people when they are in litter “hot-spots”. This can be used to remind users of the game to be mindful of their trash, or to alert people that they are in areas where there are opportunities for big points!
Below, I have accessed the latest reports of a “Dirty Street” or “Dirty Alley” from the 311 database and created a heatmap over the city of Baltimore of the volume of reports by location in the city.
library(maps)
library(tidyverse)
library(ggmap)
md <- filter(map_data("state"), region == "maryland")
md_county <- filter(map_data("county"), region=="maryland")
bmore <- filter(md_county, subregion=="baltimore city")
lat.lim <- c(min(bmore$lat, na.rm=TRUE),
max(bmore$lat, na.rm=TRUE))
lon.lim <- c(min(bmore$long, na.rm=TRUE),
max(bmore$long, na.rm=TRUE))
bmore_map <-ggmap(get_stamenmap(bbox = c(left = lon.lim[1], bottom = lat.lim[1],
right = lon.lim[2], top=lat.lim[2]),
zoom = 12, scale = 5,
maptype ='terrain',
color = 'color'))
bmore_map +
stat_density2d(data=litter.dat, mapping=aes(x=Longitude, y=Latitude, fill=..level..), alpha=0.1,
size=0.01, bins=100, geom="polygon") +
labs(title="Heat Map of Baltimore 311 Dirty Street/Alley Reports",
fill="Reports")One of the primary purposes of the app will be to collect data from the users to gather even more information of areas that need cleaning up! The app will provide an easy way to report information similar to that displayed above, and more! In addition to reporting locations of dirty alleys or streets, the app will award points to users who identify the locations of trash cans and trash cans that are overflowing. A major feature of the app will be to notify users where trash cans are so that they can throw away their trash. Since this data is not easily accessible, it will be up to users to provide information for the app. Below I have reproduced the plot above, with a point for a trash can near JHSPH. The point can be colored based on whether the can is overflowing or not.
trash_cans <- data.frame(lat=c(39.299751,39.285668),
lon=c(-76.590883,-76.590464),
overflow=c("Not Overflowing","Overflowing"))
bmore_map +
stat_density2d(data=litter.dat, mapping=aes(x=Longitude, y=Latitude, fill=..level..), alpha=0.1,
size=0.01, bins=100, geom="polygon") +
geom_point(data=trash_cans, aes(x=lon, y=lat, color=overflow), shape=15) +
scale_color_manual(values=c("green", "red")) +
labs(title="Heat Map of Baltimore 311 Dirty Street/Alley Reports",
color="Trash Cans",
fill="Reports")Liquor container waste is a widely recognized contributor to municipal litter. In particular some communities have looked to ban single-serving liquor containers (https://www.telegram.com/news/20190609/communities-seek-ways-to-nip-liquor-bottle-litter-in-bud). With regard to litter, the City of Oakland has grouped liquor stores along with fast food businesses, convenience markets, and gasoline station markets, targeting all of them with an excess litter fee under Ordinance 12727 (https://www.oaklandca.gov/services/finance-dept-liens-and-excess-litter-fee).
Baltimore City makes available a data set describing liquor license granted to liquor stores from 2003 to 2018 (https://data.baltimorecity.gov/City-Services/Liquor-Stores/hew9-k3x4). It is unclear whether the data set is exhaustive, but it includes information on 4,148 licenses granted to 306 unique locations. Reported variables include licensee name, owner name, corporation name, license type, address, and geolocation.
What will be most useful for our app is the address and geolocation. With this information, we can monitor the link between garbage location and liquor store location, as well as send trash disposal reminders to customers exiting liquor stores. This data is not ideal because the locations may be out of date, but it is a good start.
require(ggmap)
liquor = read.csv('Liquor_Stores.csv')
liquor$coord = NA
liquor$lat = NA
liquor$lon = NA
for(i in 1:nrow(liquor)){
liquor$coord[i] = strsplit(toString(liquor$Location.1[i],sep=''),
"[[:digit:]]{5}[[:space:]][(]")[[1]][2]
if (!is.na(liquor$coord)[i]) {
liquor$coord[i] = paste('(', liquor$coord[i], sep='')
liquor$lat[i] = as.numeric(substring(strsplit(liquor$coord[i], ',')[[1]][1],first=2))
liquor$lon[i] = as.numeric(substring(strsplit(liquor$coord[i], ',')[[1]][2], first=1,
last=nchar(strsplit(liquor$coord[i], ',')[[1]][2])-1))
}
}
lat.lim <- c(min(liquor$lat, na.rm=TRUE),
max(liquor$lat, na.rm=TRUE))
lon.lim <- c(min(liquor$lon, na.rm=TRUE),
max(liquor$lon, na.rm=TRUE))
p <- ggmap(get_stamenmap(bbox = c(left = -76.72, bottom = 39.2,
right = -76.5, top=39.4),
zoom = 12, scale = 5,
maptype ='terrain',
color = 'color'))
p = p+ geom_point(aes(x = lon, y = lat), data = liquor, size = 1, col='red')
p + ggtitle('Liquor store locations in Baltimore')We may be interested in which corporations have been granted the most licenses, since we may reach out to them for coupon partnerships or for their support in trash management.
sort(table(liquor$CorpName),decreasing=TRUE)[1:10]##
## N/A READ'S, INC.
## 315 147
## BONA, INC. EDDIE'S OF EAGER STREET, INC.
## 41 41
## LEES FAMILY LIQUOR, INC. ARIDNAR CORPORATION
## 41 39
## ATLANTIC CATERERS, INC. BAY ISLAND SEAFOOD CARRYOUT, INC.
## 39 39
## CHI-SUNG, INC. FIBUS DRUG STORE, INC.
## 39 39
The data set has a “description” column, which contains only two levels.
pie(table(liquor$Description), main='Liquor store license description')Some people have unique names which make them easy to find online, and therefore easy to contact. In fact, about 15% of the licenses were given to owners whose first names (for current purposes, defined as part of name before first space) do not appear in the R babynames dataset, which lists all names given to at least five babies in one year from 1880 to 2017 according to Social Security Administration records.
require(babynames)## Loading required package: babynames
liquor$nameInCensus = NA
namesInCensus = toupper(unique(babynames$name))
for(i in 1:nrow(liquor)){
name = ifelse(grepl('[[:space:]]', toString(liquor$LicenseeFirstName[i])),
strsplit(toString(liquor$LicenseeFirstName[i]), '[[:space:]]')[[1]][1],
toString(liquor$LicenseeFirstName[i]))
liquor$nameInCensus[i] = name %in% namesInCensus
}
mean(liquor$nameInCensus)## [1] 0.8519769
Here is President and COO of Northern Pharmacy, Pepper K. Mintz.